﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ViewFeedback : System.Web.UI.Page
{
    private bussiness bus;
    public string notification ="";
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            if (Session["admin"] != null)
            {
                load_data();
                if (table.Rows.Count == 0)
                {
                    notification = "Do not have any feedback";
                }

            }
            else
            {
                Response.Redirect("blankAdmin.aspx");
            }
           
        }
    }
    private DataTable table;
    private void load_data()
    {
        bussiness bus = new bussiness();
        table = bus.getview_feedback();
        GridView1.DataSource = table;
        GridView1.DataBind();
    }


    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        load_data();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        bus = new bussiness();
        int id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
        bus.deleteFeedback(id);
        load_data();
    }
}